//封装一个获取json的接口方法
export function jsonp({
    url,
    params={},
    success
}){
    let callbackName='jsonp_callback'+Date.now()+Math.random().toString().substr(2,5)
    let script =document.createElement('script')
    let baseUrl=`${url}?callback=${callbackName}`
}
for(let item in params){
    baseUrl+=`&${item}=${params[item]}`
}
script.src=baseUrl
document.body.appendChild(script)

window[callbackName]=(res)=>{
    success(res)
    delete window[callbackName]
    document.body.removeChild(script)
}